#include"RecDown.h"
//E::=T{[+-]T}*
//P::=(E) | N
//T::=P{[*/]p}*
//N::=['0'-'9']+
//G0 ::= E with init and geting answer.

char str[100] = "";
int pos;
node_t* getG0()
{
    scanf("%s", str);
    pos = 0;
    node_t* val = getE();
    if(str[pos] == '/0')
        return val;
}
node_t* getN()
{
    int val = 0;
    while('0' <= str[pos] && str[pos] <= '9')
    {
        val = val*10 + str[pos] - '0';
        pos++;
    }
    return nodeNew(NUMBER, val, NULL, NULL);
}
node_t* getP()
{
    node_t* val = NULL;
    if(str[pos] == '(')
    {
        pos++;
        val = getE();
        if(str[pos] == ')') pos++;
        return val;
    }
    else
    {
        val = getN();
        //if(str[pos] == ')') pos++;
        return val;
    }
}
node_t* getE()
{
    node_t* val = getT();
    while(str[pos] == '+')
    {
        pos++;
        val = nodeNew(PLUS, getT(), val);
    }
    return val;
}
node_t* getT()
{
    node_t* val = getP();
    while(str[pos] == '*')
    {
        pos++;
        val = nodeNew(MUL, getP(), val);
    }
    return val;
}

